const Koa = require('koa');
// 处理请求体
const bodyParser = require('koa-bodyparser')
// 处理跨域
const cors = require('koa2-cors')
// 静态资源部署
const koaStatic = require('koa-static')

// 引入首页路由
const homeRouter = require('./routes/home')
// 引入游戏库路由
const gameStoreRouter = require('./routes/gameStore')
// 引入游戏购买详情路由
const gameDetail = require('./routes/gameDetail')
// 引入用户路由
const userRouter = require('./routes/user')
// 引入优惠券路由
const couponRouter = require('./routes/coupons')
// 引入文章详细内容路由
const articleRouter = require('./routes/article')

// 引入数据库
const connection = require('./database/dataBase')

const app = new Koa()

app.use(cors())
app.use(bodyParser())
app.use(koaStatic('./public'))

// 应用路由方法
app.use(homeRouter.routes())
app.use(gameStoreRouter.routes())
app.use(gameDetail.routes())
app.use(userRouter.routes())
app.use(couponRouter.routes())
app.use(articleRouter.routes())

// 启动服务器
app.listen(8000, '192.168.2.2', () => {
  console.log('192.168.0.107:8000服务器启动成功');
})